﻿// See https://aka.ms/new-console-template for more information

using SQLite;
using SqliteDemo;

Console.WriteLine("Hello, World!");

var connection = new SQLiteConnection(Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
    "contacts.sqlite3"));

connection.CreateTable<Contact>();

var contact =
    new Contact {
        Name = "Contact 1",
        PhoneNumber = "+86 13800 138000"
    };

connection.Insert(contact);

contact = connection.Table<Contact>().First(
    p => p.PhoneNumber.Contains("138"));
Console.WriteLine(contact.Name);

connection.Close();

File.Delete(Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
    "contacts.sqlite3"));